<?php 
    session_start();
    require_once("../includes/public.inc.php");
    $userinfo = isset($_SESSION['userinfo'])?$_SESSION['userinfo']:'';
    $openid = isset($_SESSION['openid'])?$_SESSION['openid']:'';
    if (!empty($openid)) {
    	$openusers =  mysql_fetch_array(mysql_query("select * from ".DBQIAN."users where openid='".$openid."' order by id desc limit 1"));
    	$hb =array();
        $hongblog = mysql_query("select * from ".DBQIAN."exchangeuser where wx_user='".$openid."'"); 
        $hongbtotal = mysql_fetch_assoc(mysql_query("select sum(credit) as hbtotal from ".DBQIAN."exchangeuser where wx_user='".$openid."'"));
	    while($row=mysql_fetch_assoc($hongblog))
		{
			 $hb[] = $row;	
		} 
    }else
    {
       echo "<script>alert('非法进入！');history.back();</script>";
       exit;
    }
 
?>
<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,user-scalable=no,maximum-scale=1,initial-scale=1">
<title>红包记录</title>
<link type="text/css" href="css/css.css" rel="stylesheet" />
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<ul class="top-tool" style="top:0px; left:0px">
    <span class="back"><a href="javascript:history.go(-1)"><img src="./image/back_icon.png"></a></span>
    <span class="title">红包记录</span>
</ul>
<div style="height:50px"></div>
<div id="xq" class="pz-panel">
	<ul class="navs">
	<li><img src="<?=$openusers['headimg_url']?>" alt="头像"><p><?=$openusers['name']?></p></li>
	<li class="center"><img src="./image/tx_icon.png"><p>我的红包：<?=$hongbtotal['hbtotal']?></p></li>
	<li><img src="./image/hb_icon.png"><p>领取个数：<?=count($hb)?></p></li>
	</ul>
</div>
<div id="xq" class="pz-panel" style="margin-bottom:30px;">
<section id="cd-timeline" class="cd-container">
    <!--此处代码有数据时遍历用-->
    <? foreach ($hb as $h):?>
        <div class="cd-timeline-block">
            <div class="cd-timeline-img cd-movie">
                <img src="./image/hb.png" /> 
            </div>
            <div class="cd-timeline-content">
                <h4><?=$h['credit']?>元红包</h4>
                 <p>领取时间：<?=$h['time']?></p>
            </div>
        </div>
     <?endforeach;?> 
</section>
</div>
<div class="footer-tool">
	<div style="padding:0px;position:relative;margin:8px 6px;">
        <ul class="nav">
        <li onClick="location.href='hblog.php'"><img src="./image/hb_icon.png"><p>红包</p></li>
        <li onClick="location.href='cashlog.php'"><img src="./image/tx_icon.png"><p>提现</p></li>
        <li onClick="location.href='shop.php'"><img src="./image/cp_icon.png"><p>产品</p></li>
        <li style="border-right:none" onClick="location.href='person.php'">
           <img src="./image/gr_icon.png"><p>我的</p>
        </li>
        </ul>
	    <div style="clear:left">
	    </div>
	</div>
</div>
</body>
</html>
